package io.renren.modules.cat.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.cat.entity.CoitionRecordEntity;
import io.renren.modules.cat.service.CoitionRecordService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author gaoan
 * @email gao@gmail.com
 * @date 2022-04-20 15:07:11
 */
@RestController
@RequestMapping("cat/coitionrecord")
public class CoitionRecordController {
    @Autowired
    private CoitionRecordService coitionRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cat:coitionrecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = coitionRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{catIdentify}")
    @RequiresPermissions("cat:coitionrecord:info")
    public R info(@PathVariable("catIdentify") Integer catIdentify){
		CoitionRecordEntity coitionRecord = coitionRecordService.getById(catIdentify);

        return R.ok().put("coitionRecord", coitionRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cat:coitionrecord:save")
    public R save(@RequestBody CoitionRecordEntity coitionRecord){
		coitionRecordService.save(coitionRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cat:coitionrecord:update")
    public R update(@RequestBody CoitionRecordEntity coitionRecord){
		coitionRecordService.updateById(coitionRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cat:coitionrecord:delete")
    public R delete(@RequestBody Integer[] catIdentifys){
		coitionRecordService.removeByIds(Arrays.asList(catIdentifys));

        return R.ok();
    }

}
